package servletpackage;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import news.bll.topic.TopicDaoImpl;
import news.entity.Topic;

public class ShowTopicsServlet extends HttpServlet {

	/**
	 * 
	 */
	private static final long serialVersionUID = 5592237707813189781L;

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		this.doPost(req, resp);
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		req.setCharacterEncoding("utf-8");
		resp.setContentType("text/html;charset=UTF-8");
		TopicDaoImpl tdi = new TopicDaoImpl();
		List<Topic> topics = tdi.getAllTopics();
		req.setAttribute("topics", topics);
		req.getRequestDispatcher("/WEB-INF/jsp/topic_edit.jsp").forward(req, resp);
	}
}
